<?php
namespace Admin\Controller;
use Think\Controller;

class IndexController extends Controller
{
	public function index()
	{
		$info['system'] = PHP_OS;
		$info['software'] = I('server.SERVER_SOFTWARE');
		$info['mode'] = php_sapi_name();
		$info['addr'] = I('server.SERVER_ADDR');
		$info['name'] = I('server.SERVER_NAME');
		$this->assign('info', $info);
		return $this->display();
	}

	private function _deleteDir($R){
		$handle = opendir($R);
		while(($item = readdir($handle)) !== false){
			if($item != '.' and $item != '..'){
				if(is_dir($R.'/'.$item)){
					$this->_deleteDir($R.'/'.$item);
				}else{
					if(!unlink($R.'/'.$item))
						die('error!');
				}
			}
		}
		closedir( $handle );
		return rmdir($R); 
	}
	
	public function clearRuntime(){

		$R = $_GET['path'] ? $_GET['path'] : RUNTIME_PATH;
		if($this->_deleteDir($R))
			die("cleared!");

	}
}